<?php
/**
 * Created by PhpStorm.
 * User: Digvijay
 * Date: 3/17/14
 * Time: 1:03 PM
 */

use Doctrine\ORM\Tools\SchemaTool;

class Schema extends CI_Controller {
    public $em;

    function __construct() {
        parent::__construct();
        $this->em = $this->doctrine->em;
    }

    function index() {
        try {
            $schemaTool = new SchemaTool($this->em);
            $classes = $this->em->getMetadataFactory()->getAllMetadata();
            $schemaTool->updateSchema($classes);
            echo "<div style='margin:10% 40% 10% 40%;height:10%;padding:5% 5% 5% 5%;background-color:gainsboro'>";
            echo "<h4 align='center'>Schema Updated</h4>";
            echo "<div>";
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }

    function digvijay() {
        $user = new User();
        $user->setFirstName("Digvijay");
        $user->setLastName("Mohite");
        $user->setUsername("digvijay");
        $user->setPassword("digvijay");
        $user->setEmail("digvijaymohite27@gmail.com");
        $user->setRole("ADMINISTRATOR");
        $this->em->persist($user);
        $this->em->flush();
        echo "User Create";
    }
}